/*      */ package com.zimbra.qa.unittest;
/*      */ 
/*      */ import com.google.common.base.Strings;
/*      */ import com.google.common.collect.Lists;
/*      */ import com.google.common.collect.Maps;
/*      */ import com.google.common.io.Closeables;
/*      */ import com.zimbra.client.ZFolder;
/*      */ import com.zimbra.client.ZFolder.View;
/*      */ import com.zimbra.client.ZMailbox;
/*      */ import com.zimbra.client.ZMailbox.Options;
/*      */ import com.zimbra.client.ZMessage;
/*      */ import com.zimbra.common.account.Key.AccountBy;
/*      */ import com.zimbra.common.calendar.ICalTimeZone;
/*      */ import com.zimbra.common.calendar.ParsedDateTime;
/*      */ import com.zimbra.common.calendar.WellKnownTimeZones;
/*      */ import com.zimbra.common.calendar.ZCalendar.ICalTok;
/*      */ import com.zimbra.common.calendar.ZCalendar.ZCalendarBuilder;
/*      */ import com.zimbra.common.calendar.ZCalendar.ZComponent;
/*      */ import com.zimbra.common.calendar.ZCalendar.ZParameter;
/*      */ import com.zimbra.common.calendar.ZCalendar.ZProperty;
/*      */ import com.zimbra.common.calendar.ZCalendar.ZVCalendar;
/*      */ import com.zimbra.common.httpclient.HttpClientUtil;
/*      */ import com.zimbra.common.localconfig.DebugConfig;
/*      */ import com.zimbra.common.localconfig.KnownKey;
/*      */ import com.zimbra.common.localconfig.LC;
/*      */ import com.zimbra.common.service.ServiceException;
/*      */ import com.zimbra.common.soap.Element.XMLElement;
/*      */ import com.zimbra.common.soap.W3cDomUtil;
/*      */ import com.zimbra.common.soap.XmlParseException;
/*      */ import com.zimbra.common.util.ByteUtil;
/*      */ import com.zimbra.common.util.Log;
/*      */ import com.zimbra.common.util.ZimbraLog;
/*      */ import com.zimbra.cs.account.Account;
/*      */ import com.zimbra.cs.account.Provisioning;
/*      */ import com.zimbra.cs.account.Server;
/*      */ import com.zimbra.cs.dav.DavElements;
/*      */ import com.zimbra.cs.dav.resource.UrlNamespace;
/*      */ import java.io.ByteArrayInputStream;
/*      */ import java.io.File;
/*      */ import java.io.IOException;
/*      */ import java.io.InputStream;
/*      */ import java.io.PrintStream;
/*      */ import java.io.StringWriter;
/*      */ import java.io.UnsupportedEncodingException;
/*      */ import java.util.Arrays;
/*      */ import java.util.Collections;
/*      */ import java.util.Date;
/*      */ import java.util.GregorianCalendar;
/*      */ import java.util.Iterator;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import javax.xml.bind.DatatypeConverter;
/*      */ import javax.xml.namespace.NamespaceContext;
/*      */ import javax.xml.xpath.XPath;
/*      */ import javax.xml.xpath.XPathConstants;
/*      */ import javax.xml.xpath.XPathExpression;
/*      */ import javax.xml.xpath.XPathExpressionException;
/*      */ import javax.xml.xpath.XPathFactory;
/*      */ import junit.framework.Assert;
/*      */ import junit.framework.TestCase;
/*      */ import net.fortuna.ical4j.model.TimeZoneRegistry;
/*      */ import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
/*      */ import org.apache.commons.httpclient.Header;
/*      */ import org.apache.commons.httpclient.HttpClient;
/*      */ import org.apache.commons.httpclient.HttpMethod;
/*      */ import org.apache.commons.httpclient.StatusLine;
/*      */ import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
/*      */ import org.apache.commons.httpclient.methods.DeleteMethod;
/*      */ import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
/*      */ import org.apache.commons.httpclient.methods.GetMethod;
/*      */ import org.apache.commons.httpclient.methods.PostMethod;
/*      */ import org.apache.commons.httpclient.methods.PutMethod;
/*      */ import org.dom4j.QName;
/*      */ import org.w3c.dom.Document;
/*      */ import org.w3c.dom.Node;
/*      */ import org.w3c.dom.NodeList;
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ public class TestCalDav
/*      */   extends TestCase
/*      */ {
/*   98 */   static final TimeZoneRegistry tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry();
/*   99 */   private static String NAME_PREFIX = "TestCalDav";
/*  100 */   private static String USER_NAME = "user1";
/*  101 */   private static String DAV1 = "dav1";
/*  102 */   private static String DAV2 = "dav2";
/*  103 */   private static String DAV3 = "dav3";
/*      */   private static final Map<String, String> caldavNSMap;
/*      */   static final String calendar_query_etags_by_vevent = "<calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\">\n  <D:prop>\n    <D:getetag/>\n  </D:prop>\n  <filter>\n    <comp-filter name=\"VCALENDAR\">\n      <comp-filter name=\"VEVENT\"/>\n    </comp-filter>\n  </filter>\n</calendar-query>";
/*      */   
/*      */   public static class MkColMethod extends EntityEnclosingMethod {
/*  108 */     public String getName() { return "MKCOL"; }
/*      */     
/*      */     public MkColMethod(String uri) {
/*  111 */       super();
/*      */     }
/*      */   }
/*      */   
/*      */   public static class PropPatchMethod extends EntityEnclosingMethod
/*      */   {
/*      */     public String getName() {
/*  118 */       return "PROPPATCH";
/*      */     }
/*      */     
/*  121 */     public PropPatchMethod(String uri) { super(); }
/*      */   }
/*      */   
/*      */   public static class PropFindMethod extends EntityEnclosingMethod
/*      */   {
/*      */     public String getName()
/*      */     {
/*  128 */       return "PROPFIND";
/*      */     }
/*      */     
/*  131 */     public PropFindMethod(String uri) { super(); }
/*      */   }
/*      */   
/*      */   public static class ReportMethod extends EntityEnclosingMethod
/*      */   {
/*      */     public String getName()
/*      */     {
/*  138 */       return "REPORT";
/*      */     }
/*      */     
/*  141 */     public ReportMethod(String uri) { super(); }
/*      */   }
/*      */   
/*      */ 
/*      */   static
/*      */   {
/*  147 */     Map<String, String> aMap = Maps.newHashMapWithExpectedSize(2);
/*  148 */     aMap.put("D", "DAV:");
/*  149 */     aMap.put("C", "urn:ietf:params:xml:ns:caldav");
/*  150 */     caldavNSMap = Collections.unmodifiableMap(aMap);
/*      */   }
/*      */   
/*      */   public static class NamespaceContextForXPath implements NamespaceContext {
/*      */     private final Map<String, String> nsMap;
/*      */     
/*      */     public NamespaceContextForXPath(Map<String, String> nsMap) {
/*  157 */       this.nsMap = nsMap;
/*      */     }
/*      */     
/*  160 */     public static NamespaceContextForXPath forCalDAV() { return new NamespaceContextForXPath(TestCalDav.caldavNSMap); }
/*      */     
/*      */ 
/*      */     public String getNamespaceURI(String prefix)
/*      */     {
/*  165 */       if (prefix == null) {
/*  166 */         throw new NullPointerException("Null prefix");
/*      */       }
/*      */       
/*  169 */       String nsURI = (String)this.nsMap.get(prefix);
/*  170 */       if (nsURI == null) {
/*  171 */         nsURI = "";
/*  172 */         ZimbraLog.test.info("NamespaceContextForXPath.getNamespaceURI(prefix) - Unexpected prefix %s", new Object[] { prefix });
/*      */       }
/*  174 */       return nsURI;
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public String getPrefix(String uri)
/*      */     {
/*  182 */       throw new UnsupportedOperationException();
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public Iterator getPrefixes(String uri)
/*      */     {
/*  190 */       throw new UnsupportedOperationException();
/*      */     }
/*      */   }
/*      */   
/*      */   public static ParsedDateTime parsedDateTime(int year, int month, int day, int hour, int min, ICalTimeZone icalTimeZone)
/*      */   {
/*  196 */     GregorianCalendar date = new GregorianCalendar();
/*  197 */     date.set(1, year);
/*  198 */     date.set(2, month);
/*  199 */     date.set(5, month);
/*  200 */     date.set(11, hour);
/*  201 */     date.set(12, min);
/*  202 */     date.set(13, 0);
/*  203 */     return ParsedDateTime.fromUTCTime(date.getTimeInMillis(), icalTimeZone);
/*      */   }
/*      */   
/*      */   public static ZCalendar.ZProperty attendee(Account acct, ZCalendar.ICalTok role, ZCalendar.ICalTok cutype, ZCalendar.ICalTok partstat) {
/*  207 */     ZCalendar.ZProperty att = new ZCalendar.ZProperty(ZCalendar.ICalTok.ATTENDEE, "mailto:" + acct.getName());
/*  208 */     String displayName = acct.getDisplayName();
/*  209 */     if (Strings.isNullOrEmpty(displayName)) {
/*  210 */       displayName = acct.getName().substring(0, acct.getName().indexOf("@"));
/*      */     }
/*  212 */     att.addParameter(new ZCalendar.ZParameter(ZCalendar.ICalTok.CN, displayName));
/*  213 */     att.addParameter(new ZCalendar.ZParameter(ZCalendar.ICalTok.ROLE, role.toString()));
/*  214 */     att.addParameter(new ZCalendar.ZParameter(ZCalendar.ICalTok.CUTYPE, cutype.toString()));
/*  215 */     att.addParameter(new ZCalendar.ZParameter(ZCalendar.ICalTok.PARTSTAT, partstat.toString()));
/*  216 */     return att;
/*      */   }
/*      */   
/*      */   public static ZCalendar.ZProperty organizer(Account acct) {
/*  220 */     ZCalendar.ZProperty org = new ZCalendar.ZProperty(ZCalendar.ICalTok.ORGANIZER, "mailto:" + acct.getName());
/*  221 */     String displayName = acct.getDisplayName();
/*  222 */     if (Strings.isNullOrEmpty(displayName)) {
/*  223 */       displayName = acct.getName().substring(0, acct.getName().indexOf("@"));
/*      */     }
/*  225 */     org.addParameter(new ZCalendar.ZParameter(ZCalendar.ICalTok.CN, displayName));
/*  226 */     return org;
/*      */   }
/*      */   
/*      */   public String exampleCancelIcal(Account organizer, Account attendee1, Account attendee2) throws IOException {
/*  230 */     ZCalendar.ZVCalendar vcal = new ZCalendar.ZVCalendar();
/*  231 */     vcal.addVersionAndProdId();
/*      */     
/*  233 */     vcal.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.METHOD, ZCalendar.ICalTok.CANCEL.toString()));
/*  234 */     ICalTimeZone tz = ICalTimeZone.lookupByTZID("Africa/Harare");
/*  235 */     vcal.addComponent(tz.newToVTimeZone());
/*  236 */     ZCalendar.ZComponent vevent = new ZCalendar.ZComponent(ZCalendar.ICalTok.VEVENT);
/*  237 */     ParsedDateTime dtstart = parsedDateTime(2020, 3, 1, 9, 0, tz);
/*  238 */     vevent.addProperty(dtstart.toProperty(ZCalendar.ICalTok.DTSTART, false));
/*  239 */     ParsedDateTime dtend = parsedDateTime(2020, 3, 1, 13, 0, tz);
/*  240 */     vevent.addProperty(dtend.toProperty(ZCalendar.ICalTok.DTEND, false));
/*  241 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.DTSTAMP, "20140108T224700Z"));
/*  242 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.SUMMARY, "Meeting for fun"));
/*  243 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.UID, "d123f102-42a7-4283-b025-3376dabe53b3"));
/*  244 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.STATUS, ZCalendar.ICalTok.CANCELLED.toString()));
/*  245 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.SEQUENCE, "1"));
/*  246 */     vevent.addProperty(organizer(organizer));
/*  247 */     vevent.addProperty(attendee(attendee1, ZCalendar.ICalTok.REQ_PARTICIPANT, ZCalendar.ICalTok.INDIVIDUAL, ZCalendar.ICalTok.NEEDS_ACTION));
/*  248 */     vevent.addProperty(attendee(attendee2, ZCalendar.ICalTok.REQ_PARTICIPANT, ZCalendar.ICalTok.INDIVIDUAL, ZCalendar.ICalTok.NEEDS_ACTION));
/*  249 */     vcal.addComponent(vevent);
/*  250 */     StringWriter calWriter = new StringWriter();
/*  251 */     vcal.toICalendar(calWriter);
/*  252 */     String icalString = calWriter.toString();
/*  253 */     Closeables.closeQuietly(calWriter);
/*  254 */     return icalString;
/*      */   }
/*      */   
/*      */   public static class HttpMethodExecutor {
/*      */     public int respCode;
/*      */     public int statusCode;
/*      */     public String statusLine;
/*      */     public Header[] respHeaders;
/*      */     public byte[] responseBodyBytes;
/*      */     
/*      */     public HttpMethodExecutor(HttpClient client, HttpMethod method, int expectedCode) throws IOException {
/*      */       try {
/*  266 */         this.respCode = HttpClientUtil.executeMethod(client, method);
/*  267 */         this.statusCode = method.getStatusCode();
/*  268 */         this.statusLine = method.getStatusLine().toString();
/*      */         
/*  270 */         this.respHeaders = method.getResponseHeaders();
/*  271 */         StringBuilder hdrsSb = new StringBuilder();
/*  272 */         for (Header hdr : this.respHeaders) {
/*  273 */           hdrsSb.append(hdr.toString());
/*      */         }
/*  275 */         InputStream responseStream = method.getResponseBodyAsStream();??? = null;
/*  276 */         try { if (responseStream == null) {
/*  277 */             this.responseBodyBytes = null;
/*  278 */             ZimbraLog.test.debug("RESPONSE (no content):\n%s\n%s\n\n", new Object[] { this.statusLine, hdrsSb });
/*      */           } else {
/*  280 */             this.responseBodyBytes = ByteUtil.getContent(responseStream, -1);
/*  281 */             ZimbraLog.test.debug("RESPONSE:\n%s\n%s\n%s\n\n", new Object[] { this.statusLine, hdrsSb, new String(this.responseBodyBytes) });
/*      */           }
/*      */         }
/*      */         catch (Throwable localThrowable1)
/*      */         {
/*  275 */           ??? = localThrowable1;throw localThrowable1;
/*      */ 
/*      */ 
/*      */ 
/*      */         }
/*      */         finally
/*      */         {
/*      */ 
/*      */ 
/*  284 */           if (responseStream != null) if (??? != null) try { responseStream.close(); } catch (Throwable x2) { ???.addSuppressed(x2); } else responseStream.close(); }
/*  285 */         Assert.assertEquals("Response code", expectedCode, this.respCode);
/*  286 */         Assert.assertEquals("Status code", expectedCode, this.statusCode);
/*      */       } catch (IOException e) {
/*  288 */         ZimbraLog.test.debug("Exception thrown", e);
/*  289 */         Assert.fail("Unexpected Exception" + e);
/*  290 */         throw e;
/*      */       } finally {
/*  292 */         method.releaseConnection();
/*      */       }
/*      */     }
/*      */     
/*      */     public static HttpMethodExecutor execute(HttpClient client, HttpMethod method, int expectedCode) throws IOException
/*      */     {
/*  298 */       return new HttpMethodExecutor(client, method, expectedCode);
/*      */     }
/*      */     
/*      */     public String getResponseAsString() {
/*  302 */       return new String(this.responseBodyBytes);
/*      */     }
/*      */   }
/*      */   
/*      */   public void testBadBasicAuth() throws Exception {
/*  307 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  308 */     String calFolderUrl = getFolderUrl(dav1, "Calendar").replaceAll("@", "%40");
/*  309 */     HttpClient client = new HttpClient();
/*  310 */     GetMethod method = new GetMethod(calFolderUrl);
/*  311 */     addBasicAuthHeaderForUser(method, dav1, "badPassword");
/*  312 */     HttpMethodExecutor.execute(client, method, 401);
/*      */   }
/*      */   
/*      */   public void testPostToSchedulingOutbox() throws Exception {
/*  316 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  317 */     Account dav2 = TestUtil.createAccount(DAV2);
/*  318 */     Account dav3 = TestUtil.createAccount(DAV3);
/*  319 */     String url = getSchedulingOutboxUrl(dav1, dav1);
/*  320 */     HttpClient client = new HttpClient();
/*  321 */     PostMethod method = new PostMethod(url);
/*  322 */     addBasicAuthHeaderForUser(method, dav1);
/*  323 */     method.addRequestHeader("Content-Type", "text/calendar");
/*  324 */     method.addRequestHeader("Originator", "mailto:" + dav1.getName());
/*  325 */     method.addRequestHeader("Recipient", "mailto:" + dav2.getName());
/*  326 */     method.addRequestHeader("Recipient", "mailto:" + dav3.getName());
/*      */     
/*  328 */     method.setRequestEntity(new ByteArrayRequestEntity(exampleCancelIcal(dav1, dav2, dav3).getBytes(), "text/calendar"));
/*      */     
/*      */ 
/*  331 */     HttpMethodExecutor.execute(client, method, 200);
/*      */   }
/*      */   
/*      */   public void testBadPostToSchedulingOutbox() throws Exception {
/*  335 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  336 */     Account dav2 = TestUtil.createAccount(DAV2);
/*  337 */     Account dav3 = TestUtil.createAccount(DAV3);
/*  338 */     String url = getSchedulingOutboxUrl(dav2, dav2);
/*  339 */     HttpClient client = new HttpClient();
/*  340 */     PostMethod method = new PostMethod(url);
/*  341 */     addBasicAuthHeaderForUser(method, dav2);
/*  342 */     method.addRequestHeader("Content-Type", "text/calendar");
/*  343 */     method.addRequestHeader("Originator", "mailto:" + dav2.getName());
/*  344 */     method.addRequestHeader("Recipient", "mailto:" + dav3.getName());
/*      */     
/*  346 */     method.setRequestEntity(new ByteArrayRequestEntity(exampleCancelIcal(dav1, dav2, dav3).getBytes(), "text/calendar"));
/*      */     
/*      */ 
/*  349 */     HttpMethodExecutor.execute(client, method, 400);
/*      */   }
/*      */   
/*      */   public static void addBasicAuthHeaderForUser(HttpMethod method, Account acct, String password) throws UnsupportedEncodingException
/*      */   {
/*  354 */     String basicAuthEncoding = DatatypeConverter.printBase64Binary(String.format("%s:%s", new Object[] { acct.getName(), password }).getBytes("UTF-8"));
/*      */     
/*  356 */     method.addRequestHeader("Authorization", "Basic " + basicAuthEncoding);
/*      */   }
/*      */   
/*      */   public static void addBasicAuthHeaderForUser(HttpMethod method, Account acct) throws UnsupportedEncodingException {
/*  360 */     addBasicAuthHeaderForUser(method, acct, "test123");
/*      */   }
/*      */   
/*      */   public static StringBuilder getLocalServerRoot() throws ServiceException {
/*  364 */     Server localServer = Provisioning.getInstance().getLocalServer();
/*  365 */     StringBuilder sb = new StringBuilder();
/*  366 */     sb.append("http://localhost:").append(localServer.getIntAttr("zimbraMailPort", 0));
/*  367 */     return sb;
/*      */   }
/*      */   
/*      */   public static String getSchedulingOutboxUrl(Account auth, Account target) throws ServiceException {
/*  371 */     StringBuilder sb = getLocalServerRoot();
/*  372 */     sb.append(UrlNamespace.getSchedulingOutboxUrl(auth.getName(), target.getName()));
/*  373 */     return sb.toString();
/*      */   }
/*      */   
/*      */   public static String getSchedulingInboxUrl(Account auth, Account target) throws ServiceException {
/*  377 */     StringBuilder sb = getLocalServerRoot();
/*  378 */     sb.append(UrlNamespace.getSchedulingInboxUrl(auth.getName(), target.getName()));
/*  379 */     return sb.toString();
/*      */   }
/*      */   
/*      */   public static String getFolderUrl(Account auth, String folderName) throws ServiceException {
/*  383 */     StringBuilder sb = getLocalServerRoot();
/*  384 */     sb.append(UrlNamespace.getFolderUrl(auth.getName(), folderName));
/*  385 */     return sb.toString();
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static Document calendarQuery(String url, Account acct)
/*      */     throws IOException, XmlParseException
/*      */   {
/*  401 */     ReportMethod method = new ReportMethod(url);
/*  402 */     addBasicAuthHeaderForUser(method, acct);
/*  403 */     HttpClient client = new HttpClient();
/*      */     
/*  405 */     method.addRequestHeader("Content-Type", "text/xml");
/*  406 */     method.setRequestEntity(new ByteArrayRequestEntity("<calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\">\n  <D:prop>\n    <D:getetag/>\n  </D:prop>\n  <filter>\n    <comp-filter name=\"VCALENDAR\">\n      <comp-filter name=\"VEVENT\"/>\n    </comp-filter>\n  </filter>\n</calendar-query>".getBytes(), "text/xml"));
/*      */     
/*  408 */     HttpMethodExecutor executor = new HttpMethodExecutor(client, method, 207);
/*  409 */     String respBody = new String(executor.responseBodyBytes, "utf-8");
/*  410 */     Document doc = W3cDomUtil.parseXMLToDoc(respBody);
/*  411 */     org.w3c.dom.Element docElement = doc.getDocumentElement();
/*  412 */     assertEquals("Report node name", "multistatus", docElement.getLocalName());
/*  413 */     return doc;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static String waitForItemInCalendarCollectionByUID(String url, Account acct, String UID, boolean expected, int timeout_millis)
/*      */     throws ServiceException, IOException
/*      */   {
/*  427 */     int orig_timeout_millis = timeout_millis;
/*  428 */     while (timeout_millis > 0) {
/*  429 */       Document doc = calendarQuery(url, acct);
/*  430 */       XPath xpath = XPathFactory.newInstance().newXPath();
/*  431 */       xpath.setNamespaceContext(NamespaceContextForXPath.forCalDAV());
/*      */       try
/*      */       {
/*  434 */         XPathExpression xPathExpr = xpath.compile("/D:multistatus/D:response/D:href/text()");
/*  435 */         NodeList result = (NodeList)xPathExpr.evaluate(doc, XPathConstants.NODESET);
/*  436 */         if (1 <= result.getLength()) {
/*  437 */           for (int ndx = 0; ndx < result.getLength(); ndx++) {
/*  438 */             Node item = result.item(ndx);
/*  439 */             String nodeValue = item.getNodeValue();
/*  440 */             if ((Strings.isNullOrEmpty(UID)) || (nodeValue.contains(UID))) {
/*  441 */               if (!expected) {
/*  442 */                 fail(String.format("item with UID '%s' unexpectedly arrived in collection '%s' within %d millisecs", new Object[] { Strings.nullToEmpty(UID), url, Integer.valueOf(orig_timeout_millis - timeout_millis) }));
/*      */               }
/*      */               
/*      */ 
/*      */ 
/*  447 */               return nodeValue;
/*      */             }
/*      */           }
/*      */         }
/*      */       } catch (XPathExpressionException e1) {
/*  452 */         ZimbraLog.test.debug("xpath problem", e1);
/*      */       }
/*      */       try {
/*  455 */         if (timeout_millis > 100) {
/*  456 */           Thread.sleep(100L);
/*  457 */           timeout_millis -= 100;
/*      */         } else {
/*  459 */           Thread.sleep(timeout_millis);
/*  460 */           timeout_millis = 0;
/*      */         }
/*      */       }
/*      */       catch (InterruptedException e) {
/*  464 */         ZimbraLog.test.debug("sleep got interrupted", e);
/*      */       }
/*      */     }
/*  467 */     if (expected) {
/*  468 */       fail(String.format("item with UID '%s' didn't arrive in collection '%s' within %d millisecs", new Object[] { Strings.nullToEmpty(UID), url, Integer.valueOf(orig_timeout_millis) }));
/*      */     }
/*      */     
/*  471 */     return null;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static String waitForNewSchedulingRequestByUID(Account acct, String UID)
/*      */     throws ServiceException, IOException
/*      */   {
/*  485 */     String url = getSchedulingInboxUrl(acct, acct);
/*  486 */     return waitForItemInCalendarCollectionByUID(url, acct, UID, true, 10000);
/*      */   }
/*      */   
/*      */   public void testCalendarQueryOnInbox() throws Exception {
/*  490 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  491 */     String url = getSchedulingInboxUrl(dav1, dav1);
/*  492 */     Document doc = calendarQuery(url, dav1);
/*  493 */     org.w3c.dom.Element rootElem = doc.getDocumentElement();
/*  494 */     assertFalse("response when there are no items should have no child elements", rootElem.hasChildNodes());
/*      */     
/*      */ 
/*  497 */     ZMailbox organizer = TestUtil.getZMailbox(USER_NAME);
/*  498 */     String subject = NAME_PREFIX + " testInvite request 1";
/*  499 */     Date startDate = new Date(System.currentTimeMillis() + 86400000L);
/*  500 */     Date endDate = new Date(startDate.getTime() + 3600000L);
/*  501 */     TestUtil.createAppointment(organizer, subject, dav1.getName(), startDate, endDate);
/*      */     
/*  503 */     waitForNewSchedulingRequestByUID(dav1, "");
/*  504 */     doc = calendarQuery(url, dav1);
/*  505 */     rootElem = doc.getDocumentElement();
/*  506 */     assertTrue("response should have child elements", rootElem.hasChildNodes());
/*      */   }
/*      */   
/*      */   public void testCalendarQueryOnOutbox() throws Exception {
/*  510 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  511 */     ZMailbox dav1mbox = TestUtil.getZMailbox(USER_NAME);
/*  512 */     String url = getSchedulingOutboxUrl(dav1, dav1);
/*  513 */     Document doc = calendarQuery(url, dav1);
/*  514 */     org.w3c.dom.Element rootElem = doc.getDocumentElement();
/*  515 */     assertFalse("response when there are no items should have no child elements", rootElem.hasChildNodes());
/*      */     
/*      */ 
/*  518 */     ZMailbox recipient = TestUtil.getZMailbox(USER_NAME);
/*  519 */     String subject = NAME_PREFIX + " testInvite request 1";
/*  520 */     Date startDate = new Date(System.currentTimeMillis() + 86400000L);
/*  521 */     Date endDate = new Date(startDate.getTime() + 3600000L);
/*  522 */     TestUtil.createAppointment(dav1mbox, subject, recipient.getName(), startDate, endDate);
/*      */     
/*  524 */     doc = calendarQuery(url, dav1);
/*  525 */     rootElem = doc.getDocumentElement();
/*      */     
/*      */ 
/*  528 */     assertFalse("response for items in outbox should have no child elements, even though we sent an invite", rootElem.hasChildNodes());
/*      */   }
/*      */   
/*      */   public void testPropFindSupportedReportSetOnInbox() throws Exception
/*      */   {
/*  533 */     Account user1 = TestUtil.getAccount(USER_NAME);
/*  534 */     checkPropFindSupportedReportSet(user1, getSchedulingInboxUrl(user1, user1), UrlNamespace.getSchedulingInboxUrl(user1.getName(), user1.getName()));
/*      */   }
/*      */   
/*      */   public void testPropFindSupportedReportSetOnOutbox() throws Exception
/*      */   {
/*  539 */     Account user1 = TestUtil.getAccount(USER_NAME);
/*  540 */     checkPropFindSupportedReportSet(user1, getSchedulingOutboxUrl(user1, user1), UrlNamespace.getSchedulingOutboxUrl(user1.getName(), user1.getName()));
/*      */   }
/*      */   
/*      */ 
/*  544 */   String propFindSupportedReportSet = "<x0:propfind xmlns:x0=\"DAV:\" xmlns:x1=\"urn:ietf:params:xml:ns:caldav\">\n  <x0:prop>\n    <x0:supported-report-set/>\n  </x0:prop>\n</x0:propfind>";
/*      */   
/*      */ 
/*      */ 
/*      */   public void checkPropFindSupportedReportSet(Account user, String fullurl, String shorturl)
/*      */     throws Exception
/*      */   {
/*  551 */     PropFindMethod method = new PropFindMethod(fullurl);
/*  552 */     addBasicAuthHeaderForUser(method, user);
/*  553 */     HttpClient client = new HttpClient();
/*      */     
/*      */ 
/*      */ 
/*  557 */     method.addRequestHeader("Content-Type", "text/xml");
/*  558 */     method.setRequestEntity(new ByteArrayRequestEntity(this.propFindSupportedReportSet.getBytes(), "text/xml"));
/*  559 */     HttpMethodExecutor executor = new HttpMethodExecutor(client, method, 207);
/*  560 */     String respBody = new String(executor.responseBodyBytes, "utf-8");
/*  561 */     com.zimbra.common.soap.Element respElem = Element.XMLElement.parseXML(respBody);
/*  562 */     assertEquals("name of top element in response", "multistatus", respElem.getName());
/*  563 */     assertTrue("top element response should have child elements", respElem.hasChildren());
/*  564 */     checkSupportedReportSet(respElem, shorturl);
/*      */   }
/*      */   
/*      */   private void checkSupportedReportSet(com.zimbra.common.soap.Element respElem, String shorturl) {
/*  568 */     boolean supportsCalendarQuery = false;
/*  569 */     for (com.zimbra.common.soap.Element r : respElem.listElements()) {
/*  570 */       assertEquals("name of sub-element in response", "response", r.getName());
/*  571 */       for (com.zimbra.common.soap.Element respEntry : r.listElements()) {
/*  572 */         if ("href".equals(respEntry.getName())) {
/*  573 */           String hrefText = respEntry.getText();
/*      */           
/*      */ 
/*  576 */           assertEquals("HREF", shorturl, hrefText);
/*  577 */         } else if ("propstat".equals(respEntry.getName())) {
/*  578 */           for (com.zimbra.common.soap.Element psEntry : respEntry.listElements()) {
/*  579 */             if ("status".equals(psEntry.getName())) {
/*  580 */               assertEquals("propstat/status", "HTTP/1.1 200 OK", psEntry.getText());
/*  581 */             } else if ("prop".equals(psEntry.getName())) {
/*  582 */               for (com.zimbra.common.soap.Element propEntry : psEntry.listElements()) {
/*  583 */                 if ("supported-report-set".equals(propEntry.getName())) {
/*  584 */                   for (com.zimbra.common.soap.Element suppRepSetEntry : propEntry.listElements()) {
/*  585 */                     assertEquals("supported-report-set child", "supported-report", suppRepSetEntry.getName());
/*      */                     
/*  587 */                     for (com.zimbra.common.soap.Element suppRepEntry : suppRepSetEntry.listElements()) {
/*  588 */                       assertEquals("supported-report child", "report", suppRepEntry.getName());
/*      */                       
/*  590 */                       for (com.zimbra.common.soap.Element repEntry : suppRepEntry.listElements()) {
/*  591 */                         if (DavElements.E_CALENDAR_QUERY.equals(repEntry.getQName())) {
/*  592 */                           supportsCalendarQuery = true;
/*      */                         }
/*      */                       }
/*      */                     }
/*      */                   }
/*      */                 } else {
/*  598 */                   fail("Unexpected element '" + propEntry.getName() + "' under " + "prop");
/*      */                 }
/*      */               }
/*      */             } else {
/*  602 */               fail("Unexpected element '" + psEntry.getName() + "' under " + "propstat");
/*      */             }
/*      */           }
/*      */         } else {
/*  606 */           fail("Unexpected element '" + respEntry.getName() + "' under " + "response");
/*      */         }
/*      */       }
/*      */     }
/*  610 */     assertTrue("calendar-query report should be advertised", supportsCalendarQuery);
/*      */   }
/*      */   
/*  613 */   final String propFindSupportedCalendarComponentSet = "<D:propfind xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n  <D:prop>\n     <C:supported-calendar-component-set/>\n  </D:prop>\n</D:propfind>";
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public void checkPropFindSupportedCalendarComponentSet(Account user, String fullurl, String shorturl, String[] compNames)
/*      */     throws Exception
/*      */   {
/*  622 */     PropFindMethod method = new PropFindMethod(fullurl);
/*  623 */     addBasicAuthHeaderForUser(method, user);
/*  624 */     HttpClient client = new HttpClient();
/*      */     
/*      */ 
/*  627 */     method.addRequestHeader("Content-Type", "text/xml");
/*  628 */     method.setRequestEntity(new ByteArrayRequestEntity("<D:propfind xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n  <D:prop>\n     <C:supported-calendar-component-set/>\n  </D:prop>\n</D:propfind>".getBytes(), "text/xml"));
/*      */     
/*  630 */     HttpMethodExecutor executor = new HttpMethodExecutor(client, method, 207);
/*  631 */     String respBody = new String(executor.responseBodyBytes, "utf-8");
/*  632 */     Document doc = W3cDomUtil.parseXMLToDoc(respBody);
/*  633 */     XPath xpath = XPathFactory.newInstance().newXPath();
/*  634 */     xpath.setNamespaceContext(NamespaceContextForXPath.forCalDAV());
/*      */     
/*      */ 
/*      */ 
/*  638 */     XPathExpression xPathExpr = xpath.compile("/D:multistatus/D:response/D:href/text()");
/*  639 */     NodeList result = (NodeList)xPathExpr.evaluate(doc, XPathConstants.NODESET);
/*  640 */     String text = (String)xPathExpr.evaluate(doc, XPathConstants.STRING);
/*  641 */     assertEquals(String.format("href '%s' should be same as '%s'", new Object[] { text, shorturl }), shorturl, text);
/*  642 */     xPathExpr = xpath.compile("/D:multistatus/D:response/D:propstat/D:status/text()");
/*  643 */     text = (String)xPathExpr.evaluate(doc, XPathConstants.STRING);
/*  644 */     assertEquals("status", "HTTP/1.1 200 OK", text);
/*  645 */     xPathExpr = xpath.compile("/D:multistatus/D:response/D:propstat/D:prop/C:supported-calendar-component-set/C:comp");
/*  646 */     result = (NodeList)xPathExpr.evaluate(doc, XPathConstants.NODESET);
/*  647 */     assertEquals("Number of comp nodes under supported-calendar-component-set", compNames.length, result.getLength());
/*  648 */     List<String> names = Arrays.asList(compNames);
/*  649 */     for (int ndx = 0; ndx < result.getLength(); ndx++) {
/*  650 */       org.w3c.dom.Element child = (org.w3c.dom.Element)result.item(ndx);
/*  651 */       String name = child.getAttribute("name");
/*  652 */       assertNotNull("comp should have a 'name' attribute", name);
/*  653 */       assertTrue(String.format("comp 'name' attribute '%s' should be one of the expected names", new Object[] { name }), names.contains(name));
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*  658 */   private final String[] componentsForBothTasksAndEvents = { "VEVENT", "VTODO", "VFREEBUSY" };
/*  659 */   private final String[] eventComponents = { "VEVENT", "VFREEBUSY" };
/*  660 */   private final String[] todoComponents = { "VTODO", "VFREEBUSY" };
/*      */   
/*  662 */   public void testPropFindSupportedCalendarComponentSetOnInbox() throws Exception { Account user1 = TestUtil.getAccount(USER_NAME);
/*  663 */     checkPropFindSupportedCalendarComponentSet(user1, getSchedulingInboxUrl(user1, user1), UrlNamespace.getSchedulingInboxUrl(user1.getName(), user1.getName()), this.componentsForBothTasksAndEvents);
/*      */   }
/*      */   
/*      */   public void testPropFindSupportedCalendarComponentSetOnOutbox() throws Exception
/*      */   {
/*  668 */     Account user1 = TestUtil.getAccount(USER_NAME);
/*  669 */     checkPropFindSupportedCalendarComponentSet(user1, getSchedulingOutboxUrl(user1, user1), UrlNamespace.getSchedulingOutboxUrl(user1.getName(), user1.getName()), this.componentsForBothTasksAndEvents);
/*      */   }
/*      */   
/*      */   public void testPropFindSupportedCalendarComponentSetOnCalendar() throws Exception
/*      */   {
/*  674 */     Account user1 = TestUtil.getAccount(USER_NAME);
/*  675 */     checkPropFindSupportedCalendarComponentSet(user1, getFolderUrl(user1, "Calendar"), UrlNamespace.getFolderUrl(user1.getName(), "Calendar"), this.eventComponents);
/*      */   }
/*      */   
/*      */   public void testPropFindSupportedCalendarComponentSetOnTasks() throws Exception
/*      */   {
/*  680 */     Account user1 = TestUtil.getAccount(USER_NAME);
/*  681 */     checkPropFindSupportedCalendarComponentSet(user1, getFolderUrl(user1, "Tasks"), UrlNamespace.getFolderUrl(user1.getName(), "Tasks"), this.todoComponents);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public void testCreateUsingClientChosenName()
/*      */     throws ServiceException, IOException
/*      */   {
/*  695 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  696 */     String davBaseName = "clientInvented.now";
/*  697 */     String calFolderUrl = getFolderUrl(dav1, "Calendar");
/*  698 */     String url = String.format("%s%s", new Object[] { calFolderUrl, davBaseName });
/*  699 */     HttpClient client = new HttpClient();
/*  700 */     PutMethod putMethod = new PutMethod(url);
/*  701 */     addBasicAuthHeaderForUser(putMethod, dav1);
/*  702 */     putMethod.addRequestHeader("Content-Type", "text/calendar");
/*      */     
/*  704 */     putMethod.setRequestEntity(new ByteArrayRequestEntity(simpleEvent(dav1).getBytes(), "text/calendar"));
/*      */     
/*  706 */     if (DebugConfig.enableDAVclientCanChooseResourceBaseName) {
/*  707 */       HttpMethodExecutor.execute(client, putMethod, 201);
/*      */     } else {
/*  709 */       HttpMethodExecutor.execute(client, putMethod, 302);
/*      */       
/*  711 */       return;
/*      */     }
/*      */     
/*  714 */     GetMethod getMethod = new GetMethod(url);
/*  715 */     addBasicAuthHeaderForUser(getMethod, dav1);
/*  716 */     HttpMethodExecutor.execute(client, getMethod, 200);
/*      */     
/*  718 */     PropFindMethod propFindMethod = new PropFindMethod(getFolderUrl(dav1, "Calendar"));
/*  719 */     addBasicAuthHeaderForUser(propFindMethod, dav1);
/*      */     
/*      */ 
/*      */ 
/*  723 */     propFindMethod.addRequestHeader("Content-Type", "text/xml");
/*  724 */     propFindMethod.addRequestHeader("Depth", "1");
/*  725 */     propFindMethod.setRequestEntity(new ByteArrayRequestEntity(propFindEtagResType.getBytes(), "text/xml"));
/*      */     
/*  727 */     HttpMethodExecutor executor = new HttpMethodExecutor(client, propFindMethod, 207);
/*  728 */     String respBody = new String(executor.responseBodyBytes, "utf-8");
/*  729 */     com.zimbra.common.soap.Element respElem = Element.XMLElement.parseXML(respBody);
/*  730 */     assertEquals("name of top element in propfind response", "multistatus", respElem.getName());
/*  731 */     assertTrue("propfind response should have child elements", respElem.hasChildren());
/*  732 */     Iterator<com.zimbra.common.soap.Element> iter = respElem.elementIterator();
/*  733 */     boolean hasCalendarHref = false;
/*  734 */     boolean hasCalItemHref = false;
/*  735 */     while (iter.hasNext()) {
/*  736 */       com.zimbra.common.soap.Element child = (com.zimbra.common.soap.Element)iter.next();
/*  737 */       if ("response".equals(child.getName())) {
/*  738 */         Iterator<com.zimbra.common.soap.Element> hrefIter = child.elementIterator("href");
/*  739 */         while (hrefIter.hasNext()) {
/*  740 */           com.zimbra.common.soap.Element href = (com.zimbra.common.soap.Element)hrefIter.next();
/*  741 */           calFolderUrl.endsWith(href.getText());
/*  742 */           hasCalendarHref = (hasCalendarHref) || (calFolderUrl.endsWith(href.getText()));
/*  743 */           hasCalItemHref = (hasCalItemHref) || (url.endsWith(href.getText()));
/*      */         }
/*      */       }
/*      */     }
/*  747 */     assertTrue("propfind response contained entry for calendar", hasCalendarHref);
/*  748 */     assertTrue("propfind response contained entry for calendar entry ", hasCalItemHref);
/*  749 */     DeleteMethod deleteMethod = new DeleteMethod(url);
/*  750 */     addBasicAuthHeaderForUser(deleteMethod, dav1);
/*  751 */     HttpMethodExecutor.execute(client, deleteMethod, 204);
/*      */   }
/*      */   
/*  754 */   private static String androidSeriesMeetingTemplate = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//dmfs.org//mimedir.icalendar//EN\nBEGIN:VTIMEZONE\nTZID:Europe/London\nX-LIC-LOCATION:Europe/London\nBEGIN:DAYLIGHT\nTZOFFSETFROM:+0000\nTZOFFSETTO:+0100\nTZNAME:BST\nDTSTART:19700329T010000\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\nEND:DAYLIGHT\nBEGIN:STANDARD\nTZOFFSETFROM:+0100\nTZOFFSETTO:+0000\nTZNAME:GMT\nDTSTART:19701025T020000\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\nEND:STANDARD\nEND:VTIMEZONE\nBEGIN:VEVENT\nDTSTART;TZID=Europe/London:20141022T190000\nDESCRIPTION:Giggle\nSUMMARY:testAndroidMeetingSeries\nRRULE:FREQ=DAILY;COUNT=15;WKST=MO\nLOCATION:Egham Leisure Centre\\, Vicarage Road\\, Egham\\, United Kingdom\nTRANSP:OPAQUE\nSTATUS:CONFIRMED\nATTENDEE;PARTSTAT=ACCEPTED;RSVP=TRUE;ROLE=REQ-PARTICIPANT:mailto:%%ORG%%\nATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;ROLE=REQ-PARTICIPANT:mailto:%%ATT%%\nDURATION:PT1H\nLAST-MODIFIED:20141021T145905Z\nDTSTAMP:20141021T145905Z\nORGANIZER:mailto:%%ORG%%\nCREATED:20141021T145905Z\nUID:%%UID%%\nBEGIN:VALARM\nTRIGGER;VALUE=DURATION:-PT15M\nACTION:DISPLAY\nDESCRIPTION:Default Event Notification\nX-WR-ALARMUID:790cd474-6135-4705-b1a0-24d4b4fc3cf5\nEND:VALARM\nEND:VEVENT\nEND:VCALENDAR\n";
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  800 */   public String androidSeriesMeetingUid = "6db50587-d283-49a1-9cf4-63aa27406829";
/*      */   
/*  802 */   public void testAndroidMeetingSeries() throws Exception { Account dav1 = TestUtil.createAccount(DAV1);
/*  803 */     Account dav2 = TestUtil.createAccount(DAV2);
/*  804 */     String calFolderUrl = getFolderUrl(dav1, "Calendar");
/*  805 */     String url = String.format("%s%s.ics", new Object[] { calFolderUrl, this.androidSeriesMeetingUid });
/*  806 */     HttpClient client = new HttpClient();
/*  807 */     PutMethod putMethod = new PutMethod(url);
/*  808 */     addBasicAuthHeaderForUser(putMethod, dav1);
/*  809 */     putMethod.addRequestHeader("Content-Type", "text/calendar");
/*      */     
/*  811 */     String body = androidSeriesMeetingTemplate.replace("%%ORG%%", dav1.getName()).replace("%%ATT%%", dav2.getName()).replace("%%UID%%", this.androidSeriesMeetingUid);
/*      */     
/*      */ 
/*  814 */     putMethod.setRequestEntity(new ByteArrayRequestEntity(body.getBytes(), "text/calendar"));
/*      */     
/*  816 */     HttpMethodExecutor.execute(client, putMethod, 201);
/*      */     
/*  818 */     String inboxhref = waitForNewSchedulingRequestByUID(dav2, this.androidSeriesMeetingUid);
/*  819 */     assertTrue("Found meeting request for newly created item", inboxhref.contains(this.androidSeriesMeetingUid));
/*      */     
/*  821 */     GetMethod getMethod = new GetMethod(url);
/*  822 */     addBasicAuthHeaderForUser(getMethod, dav1);
/*  823 */     HttpMethodExecutor.execute(client, getMethod, 200);
/*      */     
/*  825 */     PropFindMethod propFindMethod = new PropFindMethod(getFolderUrl(dav1, "Calendar"));
/*  826 */     addBasicAuthHeaderForUser(propFindMethod, dav1);
/*      */     
/*      */ 
/*      */ 
/*  830 */     propFindMethod.addRequestHeader("Content-Type", "text/xml");
/*  831 */     propFindMethod.addRequestHeader("Depth", "1");
/*  832 */     propFindMethod.setRequestEntity(new ByteArrayRequestEntity(propFindEtagResType.getBytes(), "text/xml"));
/*      */     
/*  834 */     HttpMethodExecutor executor = new HttpMethodExecutor(client, propFindMethod, 207);
/*  835 */     String respBody = new String(executor.responseBodyBytes, "utf-8");
/*  836 */     com.zimbra.common.soap.Element respElem = Element.XMLElement.parseXML(respBody);
/*  837 */     assertEquals("name of top element in propfind response", "multistatus", respElem.getName());
/*  838 */     assertTrue("propfind response should have child elements", respElem.hasChildren());
/*  839 */     Iterator<com.zimbra.common.soap.Element> iter = respElem.elementIterator();
/*  840 */     boolean hasCalendarHref = false;
/*  841 */     boolean hasCalItemHref = false;
/*  842 */     while (iter.hasNext()) {
/*  843 */       com.zimbra.common.soap.Element child = (com.zimbra.common.soap.Element)iter.next();
/*  844 */       if ("response".equals(child.getName())) {
/*  845 */         Iterator<com.zimbra.common.soap.Element> hrefIter = child.elementIterator("href");
/*  846 */         while (hrefIter.hasNext()) {
/*  847 */           com.zimbra.common.soap.Element href = (com.zimbra.common.soap.Element)hrefIter.next();
/*  848 */           calFolderUrl.endsWith(href.getText());
/*  849 */           hasCalendarHref = (hasCalendarHref) || (calFolderUrl.endsWith(href.getText()));
/*  850 */           hasCalItemHref = (hasCalItemHref) || (url.endsWith(href.getText()));
/*      */         }
/*      */       }
/*      */     }
/*  854 */     assertTrue("propfind response contained entry for calendar", hasCalendarHref);
/*  855 */     assertTrue("propfind response contained entry for calendar entry ", hasCalItemHref);
/*      */     
/*  857 */     DeleteMethod deleteMethod = new DeleteMethod(url);
/*  858 */     addBasicAuthHeaderForUser(deleteMethod, dav1);
/*  859 */     HttpMethodExecutor.execute(client, deleteMethod, 204);
/*      */   }
/*      */   
/*  862 */   static String propFindEtagResType = "<x0:propfind xmlns:x0=\"DAV:\"> <x0:prop>  <x0:getetag/>  <x0:resourcetype/> </x0:prop></x0:propfind>";
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */   public String simpleEvent(Account organizer)
/*      */     throws IOException
/*      */   {
/*  870 */     ZCalendar.ZVCalendar vcal = new ZCalendar.ZVCalendar();
/*  871 */     vcal.addVersionAndProdId();
/*      */     
/*  873 */     vcal.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.METHOD, ZCalendar.ICalTok.PUBLISH.toString()));
/*  874 */     ICalTimeZone tz = ICalTimeZone.lookupByTZID("Africa/Harare");
/*  875 */     vcal.addComponent(tz.newToVTimeZone());
/*  876 */     ZCalendar.ZComponent vevent = new ZCalendar.ZComponent(ZCalendar.ICalTok.VEVENT);
/*  877 */     ParsedDateTime dtstart = parsedDateTime(2020, 3, 1, 9, 0, tz);
/*  878 */     vevent.addProperty(dtstart.toProperty(ZCalendar.ICalTok.DTSTART, false));
/*  879 */     ParsedDateTime dtend = parsedDateTime(2020, 3, 1, 13, 0, tz);
/*  880 */     vevent.addProperty(dtend.toProperty(ZCalendar.ICalTok.DTEND, false));
/*  881 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.DTSTAMP, "20140108T224700Z"));
/*  882 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.SUMMARY, "Simple Event"));
/*  883 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.UID, "d1102-42a7-4283-b025-3376dabe53b3"));
/*  884 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.STATUS, ZCalendar.ICalTok.CONFIRMED.toString()));
/*  885 */     vevent.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.SEQUENCE, "1"));
/*      */     
/*  887 */     vcal.addComponent(vevent);
/*  888 */     StringWriter calWriter = new StringWriter();
/*  889 */     vcal.toICalendar(calWriter);
/*  890 */     String icalString = calWriter.toString();
/*  891 */     Closeables.closeQuietly(calWriter);
/*  892 */     return icalString;
/*      */   }
/*      */   
/*      */   public void testSimpleMkcol() throws Exception {
/*  896 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  897 */     StringBuilder url = getLocalServerRoot();
/*  898 */     url.append("/dav").append("/").append(dav1.getName()).append("/simpleMkcol/");
/*  899 */     MkColMethod method = new MkColMethod(url.toString());
/*  900 */     addBasicAuthHeaderForUser(method, dav1);
/*  901 */     HttpClient client = new HttpClient();
/*  902 */     HttpMethodExecutor.execute(client, method, 201);
/*      */   }
/*      */   
/*      */   public void testMkcol4addressBook() throws Exception {
/*  906 */     String xml = "<D:mkcol xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:carddav\">     <D:set>       <D:prop>         <D:resourcetype>           <D:collection/>           <C:addressbook/>         </D:resourcetype>         <D:displayname>OtherContacts</D:displayname>         <C:addressbook-description xml:lang=\"en\">Extra Contacts</C:addressbook-description>       </D:prop>     </D:set></D:mkcol>";
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  918 */     Account dav1 = TestUtil.createAccount(DAV1);
/*  919 */     StringBuilder url = getLocalServerRoot();
/*  920 */     url.append("/dav").append("/").append(dav1.getName()).append("/OtherContacts/");
/*  921 */     MkColMethod method = new MkColMethod(url.toString());
/*  922 */     addBasicAuthHeaderForUser(method, dav1);
/*  923 */     HttpClient client = new HttpClient();
/*  924 */     method.addRequestHeader("Content-Type", "text/xml");
/*  925 */     method.setRequestEntity(new ByteArrayRequestEntity(xml.getBytes(), "text/xml"));
/*  926 */     HttpMethodExecutor.execute(client, method, 207);
/*      */     
/*  928 */     ZMailbox.Options options = new ZMailbox.Options();
/*  929 */     options.setAccount(dav1.getName());
/*  930 */     options.setAccountBy(Key.AccountBy.name);
/*  931 */     options.setPassword("test123");
/*  932 */     options.setUri(TestUtil.getSoapUrl());
/*  933 */     options.setNoSession(true);
/*  934 */     ZMailbox mbox = ZMailbox.getMailbox(options);
/*  935 */     ZFolder folder = mbox.getFolderByPath("/OtherContacts");
/*  936 */     assertEquals("OtherContacts", folder.getName());
/*  937 */     assertEquals("OtherContacts default view", ZFolder.View.contact, folder.getDefaultView());
/*      */   }
/*      */   
/*      */   public String makeFreeBusyRequestIcal(Account organizer, List<Account> attendees, Date start, Date end) throws IOException
/*      */   {
/*  942 */     ZCalendar.ZVCalendar vcal = new ZCalendar.ZVCalendar();
/*  943 */     vcal.addVersionAndProdId();
/*      */     
/*  945 */     vcal.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.METHOD, ZCalendar.ICalTok.REQUEST.toString()));
/*  946 */     ZCalendar.ZComponent vfreebusy = new ZCalendar.ZComponent(ZCalendar.ICalTok.VFREEBUSY);
/*  947 */     ParsedDateTime dtstart = ParsedDateTime.fromUTCTime(start.getTime());
/*  948 */     vfreebusy.addProperty(dtstart.toProperty(ZCalendar.ICalTok.DTSTART, false));
/*  949 */     ParsedDateTime dtend = ParsedDateTime.fromUTCTime(end.getTime());
/*  950 */     vfreebusy.addProperty(dtend.toProperty(ZCalendar.ICalTok.DTEND, false));
/*  951 */     vfreebusy.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.DTSTAMP, "20140108T224700Z"));
/*  952 */     vfreebusy.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.UID, "d123f102-42a7-4283-b025-3376dabe53b3"));
/*  953 */     vfreebusy.addProperty(organizer(organizer));
/*  954 */     for (Account attendee : attendees) {
/*  955 */       vfreebusy.addProperty(new ZCalendar.ZProperty(ZCalendar.ICalTok.ATTENDEE, "mailto:" + attendee.getName()));
/*      */     }
/*  957 */     vcal.addComponent(vfreebusy);
/*  958 */     StringWriter calWriter = new StringWriter();
/*  959 */     vcal.toICalendar(calWriter);
/*  960 */     String icalString = calWriter.toString();
/*  961 */     Closeables.closeQuietly(calWriter);
/*  962 */     return icalString;
/*      */   }
/*      */   
/*      */   public HttpMethodExecutor doFreeBusyCheck(Account organizer, List<Account> attendees, Date start, Date end) throws ServiceException, IOException
/*      */   {
/*  967 */     HttpClient client = new HttpClient();
/*  968 */     String outboxurl = getSchedulingOutboxUrl(organizer, organizer);
/*  969 */     PostMethod postMethod = new PostMethod(outboxurl);
/*  970 */     postMethod.addRequestHeader("Content-Type", "text/calendar");
/*  971 */     postMethod.addRequestHeader("Originator", "mailto:" + organizer.getName());
/*  972 */     for (Account attendee : attendees) {
/*  973 */       postMethod.addRequestHeader("Recipient", "mailto:" + attendee.getName());
/*      */     }
/*      */     
/*  976 */     addBasicAuthHeaderForUser(postMethod, organizer);
/*  977 */     String fbIcal = makeFreeBusyRequestIcal(organizer, attendees, start, end);
/*  978 */     postMethod.setRequestEntity(new ByteArrayRequestEntity(fbIcal.getBytes(), "text/calendar"));
/*      */     
/*  980 */     return HttpMethodExecutor.execute(client, postMethod, 200);
/*      */   }
/*      */   
/*      */   public HttpMethodExecutor doPropPatch(Account account, String url, String body) throws IOException
/*      */   {
/*  985 */     HttpClient client = new HttpClient();
/*  986 */     PropPatchMethod propPatchMethod = new PropPatchMethod(url);
/*  987 */     addBasicAuthHeaderForUser(propPatchMethod, account);
/*  988 */     propPatchMethod.addRequestHeader("Content-Type", "text/xml");
/*  989 */     propPatchMethod.setRequestEntity(new ByteArrayRequestEntity(body.getBytes(), "text/xml"));
/*      */     
/*  991 */     return HttpMethodExecutor.execute(client, propPatchMethod, 207);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public void testPropPatchCalendarFreeBusySetSettingUsingEscapedUrls()
/*      */     throws Exception
/*      */   {
/* 1006 */     String disableFreeBusyXml = "<A:propertyupdate xmlns:A=\"DAV:\">  <A:set>    <A:prop>      <B:calendar-free-busy-set xmlns:B=\"urn:ietf:params:xml:ns:caldav\"/>    </A:prop>  </A:set></A:propertyupdate>";
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1014 */     String enableFreeBusyTemplateXml = "<A:propertyupdate xmlns:A=\"DAV:\">  <A:set>    <A:prop>      <B:calendar-free-busy-set xmlns:B=\"urn:ietf:params:xml:ns:caldav\">        <A:href>/dav/%s/Tasks/</A:href>        <A:href>/dav/%s/Calendar/</A:href>      </B:calendar-free-busy-set>    </A:prop>  </A:set></A:propertyupdate>";
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1026 */     Account dav1 = TestUtil.createAccount(DAV1);
/*      */     
/*      */ 
/* 1029 */     ZMailbox organizer = TestUtil.getZMailbox(DAV1);
/* 1030 */     String subject = NAME_PREFIX + " testInvite request 1";
/* 1031 */     Date startDate = new Date(System.currentTimeMillis() + 86400000L);
/* 1032 */     Date endDate = new Date(startDate.getTime() + 3600000L);
/* 1033 */     Date fbStartDate = new Date(startDate.getTime() - 172800000L);
/* 1034 */     Date fbEndDate = new Date(endDate.getTime() + 259200000L);
/* 1035 */     String busyTentativeMarker = "FREEBUSY;FBTYPE=BUSY";
/*      */     
/*      */ 
/* 1038 */     TestUtil.createAppointment(organizer, subject, dav1.getName(), startDate, endDate);
/*      */     
/*      */ 
/* 1041 */     String fbResponse = doFreeBusyCheck(dav1, Lists.newArrayList(new Account[] { dav1 }), fbStartDate, fbEndDate).getResponseAsString();
/* 1042 */     assertTrue(String.format("First FB check Response [%s] should contain [%s]", new Object[] { fbResponse, busyTentativeMarker }), fbResponse.contains(busyTentativeMarker));
/*      */     
/*      */ 
/* 1045 */     String inboxurl = getSchedulingInboxUrl(dav1, dav1);
/* 1046 */     doPropPatch(dav1, inboxurl, disableFreeBusyXml);
/*      */     
/* 1048 */     fbResponse = doFreeBusyCheck(dav1, Lists.newArrayList(new Account[] { dav1 }), fbStartDate, fbEndDate).getResponseAsString();
/* 1049 */     assertFalse(String.format("2nd FB check after disabling - Response [%s] should NOT contain [%s]", new Object[] { fbResponse, busyTentativeMarker }), fbResponse.contains(busyTentativeMarker));
/*      */     
/*      */ 
/* 1052 */     String enableWithRawAt = String.format(enableFreeBusyTemplateXml, new Object[] { dav1.getName(), dav1.getName() });
/* 1053 */     String encodedName = dav1.getName().replace("@", "%40");
/* 1054 */     String enableWithEncodedAt = String.format(enableFreeBusyTemplateXml, new Object[] { encodedName, encodedName });
/*      */     
/* 1056 */     doPropPatch(dav1, inboxurl, enableWithRawAt);
/*      */     
/* 1058 */     fbResponse = doFreeBusyCheck(dav1, Lists.newArrayList(new Account[] { dav1 }), fbStartDate, fbEndDate).getResponseAsString();
/* 1059 */     assertTrue(String.format("3rd FB check after enabling Response [%s] should contain [%s]", new Object[] { fbResponse, busyTentativeMarker }), fbResponse.contains(busyTentativeMarker));
/*      */     
/*      */ 
/* 1062 */     doPropPatch(dav1, inboxurl, disableFreeBusyXml);
/*      */     
/* 1064 */     fbResponse = doFreeBusyCheck(dav1, Lists.newArrayList(new Account[] { dav1 }), fbStartDate, fbEndDate).getResponseAsString();
/* 1065 */     assertFalse(String.format("4th FB check after disabling - Response [%s] should NOT contain [%s]", new Object[] { fbResponse, busyTentativeMarker }), fbResponse.contains(busyTentativeMarker));
/*      */     
/*      */ 
/* 1068 */     doPropPatch(dav1, inboxurl, enableWithEncodedAt);
/*      */     
/* 1070 */     fbResponse = doFreeBusyCheck(dav1, Lists.newArrayList(new Account[] { dav1 }), fbStartDate, fbEndDate).getResponseAsString();
/* 1071 */     assertTrue(String.format("4th FB check after enabling (encoded urls) Response [%s] should contain [%s]", new Object[] { fbResponse, busyTentativeMarker }), fbResponse.contains(busyTentativeMarker));
/*      */   }
/*      */   
/*      */ 
/* 1075 */   private static String VtimeZoneGMT_0600_0500 = "BEGIN:VCALENDAR\nBEGIN:VTIMEZONE\nTZID:GMT-06.00/-05.00\nBEGIN:STANDARD\nDTSTART:16010101T010000\nTZOFFSETTO:-0600\nTZOFFSETFROM:-0500\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYDAY=1SU;WKST=MO\nEND:STANDARD\nBEGIN:DAYLIGHT\nDTSTART:16010101T030000\nTZOFFSETTO:-0500\nTZOFFSETFROM:-0600\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=3;BYDAY=2SU;WKST=MO\nEND:DAYLIGHT\nEND:VTIMEZONE\nEND:VCALENDAR\n";
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public void testFuzzyTimeZoneMatchGMT_06()
/*      */     throws Exception
/*      */   {
/* 1094 */     ByteArrayInputStream bais = new ByteArrayInputStream(VtimeZoneGMT_0600_0500.getBytes());Throwable localThrowable2 = null;
/* 1095 */     try { ZCalendar.ZVCalendar tzcal = ZCalendar.ZCalendarBuilder.build(bais, "utf-8");
/* 1096 */       assertNotNull("tzcal", tzcal);
/* 1097 */       ZCalendar.ZComponent tzcomp = tzcal.getComponent(ZCalendar.ICalTok.VTIMEZONE);
/* 1098 */       assertNotNull("tzcomp", tzcomp);
/* 1099 */       ICalTimeZone tz = ICalTimeZone.fromVTimeZone(tzcomp);
/* 1100 */       ICalTimeZone matchtz = ICalTimeZone.lookupMatchingWellKnownTZ(tz);
/* 1101 */       assertEquals("ID of Timezone which fuzzy matches GMT=06.00/-05.00", "America/Chicago", matchtz.getID());
/*      */     }
/*      */     catch (Throwable localThrowable1)
/*      */     {
/* 1094 */       localThrowable2 = localThrowable1;throw localThrowable1;
/*      */ 
/*      */ 
/*      */     }
/*      */     finally
/*      */     {
/*      */ 
/*      */ 
/* 1102 */       if (bais != null) if (localThrowable2 != null) try { bais.close(); } catch (Throwable x2) { localThrowable2.addSuppressed(x2); } else bais.close();
/*      */     } }
/*      */   
/* 1105 */   private static String VtimeZoneGMT_0800_0700 = "BEGIN:VCALENDAR\nBEGIN:VTIMEZONE\nTZID:GMT-08.00/-07.00\nBEGIN:STANDARD\nDTSTART:16010101T010000\nTZOFFSETTO:-0800\nTZOFFSETFROM:-0700\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYDAY=1SU;WKST=MO\nEND:STANDARD\nBEGIN:DAYLIGHT\nDTSTART:16010101T030000\nTZOFFSETTO:-0700\nTZOFFSETFROM:-0800\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=3;BYDAY=2SU;WKST=MO\nEND:DAYLIGHT\nEND:VTIMEZONE\nEND:VCALENDAR\n";
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public void testFuzzyTimeZoneMatchGMT_08()
/*      */     throws Exception
/*      */   {
/* 1124 */     ByteArrayInputStream bais = new ByteArrayInputStream(VtimeZoneGMT_0800_0700.getBytes());Throwable localThrowable2 = null;
/* 1125 */     try { ZCalendar.ZVCalendar tzcal = ZCalendar.ZCalendarBuilder.build(bais, "utf-8");
/* 1126 */       assertNotNull("tzcal", tzcal);
/* 1127 */       ZCalendar.ZComponent tzcomp = tzcal.getComponent(ZCalendar.ICalTok.VTIMEZONE);
/* 1128 */       assertNotNull("tzcomp", tzcomp);
/* 1129 */       ICalTimeZone tz = ICalTimeZone.fromVTimeZone(tzcomp);
/* 1130 */       ICalTimeZone matchtz = ICalTimeZone.lookupMatchingWellKnownTZ(tz);
/* 1131 */       assertEquals("ID of Timezone which fuzzy matches GMT=08.00/-07.00", "America/Los_Angeles", matchtz.getID());
/*      */     }
/*      */     catch (Throwable localThrowable1)
/*      */     {
/* 1124 */       localThrowable2 = localThrowable1;throw localThrowable1;
/*      */ 
/*      */ 
/*      */     }
/*      */     finally
/*      */     {
/*      */ 
/*      */ 
/* 1132 */       if (bais != null) if (localThrowable2 != null) try { bais.close(); } catch (Throwable x2) { localThrowable2.addSuppressed(x2); } else bais.close();
/*      */     }
/*      */   }
/*      */   
/* 1136 */   private void attendeeDeleteFromCalendar(boolean suppressReply) throws Exception { Account dav1 = TestUtil.createAccount(DAV1);
/* 1137 */     Account dav2 = TestUtil.createAccount(DAV2);
/* 1138 */     String url = getSchedulingInboxUrl(dav1, dav1);
/* 1139 */     ReportMethod method = new ReportMethod(url);
/* 1140 */     addBasicAuthHeaderForUser(method, dav1);
/*      */     
/* 1142 */     ZMailbox organizer = TestUtil.getZMailbox(DAV2);
/* 1143 */     String subject = String.format("%s %s", new Object[] { NAME_PREFIX, suppressReply ? "testInvite which shouldNOT be replied to" : "testInvite to be auto-declined" });
/*      */     
/* 1145 */     Date startDate = new Date(System.currentTimeMillis() + 86400000L);
/* 1146 */     Date endDate = new Date(startDate.getTime() + 3600000L);
/* 1147 */     TestUtil.createAppointment(organizer, subject, dav1.getName(), startDate, endDate);
/*      */     
/*      */ 
/* 1150 */     String href = waitForNewSchedulingRequestByUID(dav1, "");
/* 1151 */     assertNotNull("href for inbox invitation", href);
/* 1152 */     String uid = href.substring(href.lastIndexOf('/') + 1);
/* 1153 */     uid = uid.substring(0, uid.indexOf(',') - 1);
/* 1154 */     String calFolderUrl = getFolderUrl(dav1, "Calendar");
/* 1155 */     String delurl = waitForItemInCalendarCollectionByUID(calFolderUrl, dav1, uid, true, 5000);
/* 1156 */     StringBuilder sb = getLocalServerRoot().append(delurl);
/* 1157 */     DeleteMethod delMethod = new DeleteMethod(sb.toString());
/* 1158 */     addBasicAuthHeaderForUser(delMethod, dav1);
/* 1159 */     if (suppressReply) {
/* 1160 */       delMethod.addRequestHeader("Schedule-Reply", "F");
/*      */     }
/*      */     
/* 1163 */     HttpClient client = new HttpClient();
/* 1164 */     HttpMethodExecutor.execute(client, delMethod, 204);
/*      */     
/* 1166 */     if (suppressReply)
/*      */     {
/* 1168 */       List<ZMessage> msgs = TestUtil.waitForMessages(organizer, "is:invite is:unread inid:2 after:\"-1month\"", 0, 2000);
/* 1169 */       if (msgs != null) {
/* 1170 */         assertEquals("Should be no DECLINE reply msg", 0, msgs.size());
/*      */       }
/*      */     } else {
/* 1173 */       List<ZMessage> msgs = TestUtil.waitForMessages(organizer, "is:invite is:unread inid:2 after:\"-1month\"", 1, 10000);
/* 1174 */       assertNotNull("inbox DECLINE reply msgs", msgs);
/* 1175 */       assertEquals("Should be 1 DECLINE reply msg", 1, msgs.size());
/* 1176 */       assertNotNull("inbox DECLINE reply msg invite", ((ZMessage)msgs.get(0)).getInvite());
/*      */     }
/*      */   }
/*      */   
/*      */   public void testAttendeeAutoDecline() throws Exception {
/* 1181 */     attendeeDeleteFromCalendar(false);
/*      */   }
/*      */   
/*      */   public void testAttendeeSuppressedAutoDecline() throws Exception {
/* 1185 */     attendeeDeleteFromCalendar(true);
/*      */   }
/*      */   
/*      */   public void setUp() throws Exception
/*      */   {
/* 1190 */     if (!TestUtil.fromRunUnitTests) {
/* 1191 */       TestUtil.cliSetup();
/* 1192 */       String tzFilePath = LC.timezone_file.value();
/* 1193 */       File tzFile = new File(tzFilePath);
/* 1194 */       WellKnownTimeZones.loadFromFile(tzFile);
/*      */     }
/* 1196 */     cleanUp();
/*      */   }
/*      */   
/*      */   public void cleanUp() throws Exception
/*      */   {
/* 1201 */     TestUtil.deleteAccount(DAV1);
/* 1202 */     TestUtil.deleteAccount(DAV2);
/* 1203 */     TestUtil.deleteAccount(DAV3);
/* 1204 */     TestUtil.deleteTestData(USER_NAME, NAME_PREFIX);
/*      */   }
/*      */   
/*      */   public static void main(String[] args)
/*      */     throws Exception
/*      */   {
/*      */     try
/*      */     {
/* 1212 */       TestUtil.runTest(TestCalDav.class);
/*      */     } catch (Exception e) {
/* 1214 */       System.out.println(e.getMessage());
/*      */     }
/*      */   }
/*      */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestCalDav.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */